<cfoutput>
	#dspDocumentHeader()#
	<h2>Discharge Summary and Aftercare Plan <span class="caption">COMAR 10.21.17.10 B, COMAR 10.21.17.10 C<span></h2>
	<form class="forms">
		<cfif PARAMS.key NEQ 0>#dspFormButtons(key=PARAMS.key, action=PARAMS.controller)#</cfif>
		<fieldset>	
			<table width="90%" cellpadding="6" align="center">
				<tr>
					<th class="left">Admission Date: <span style="font-weight: normal;">#DateFormat(document.startDate, "mmm d, yyyy")#</span></th>
					<th class="left">
						Discharge Date:
						<cfif document.endDate IS "">
							#textFieldTag(id="#PARAMS.key#-endDate", name="#PARAMS.key#s[endDate]", value="")#
						<cfelse>
							<span style="font-weight: normal;"> #DateFormat(document.endDate, "mmm d, yyyy")#</span>
						</cfif>
					</th>
					<th class="right">
						Date of Birth: 
						<cfif document.dateOfBirth IS "">
							#textFieldTag(id="#PARAMS.key#-dateOfBirth", name="#PARAMS.key#s[dateOfBirth]", value="")#
						<cfelse>
							<span style="font-weight: normal;"> #DateFormat(document.dateOfBirth, "mmm d, yyyy")#</span>
						</cfif>
					</th>
				</tr>				
				<tr>
					<th class="left">Name: <span style="font-weight: normal;">#document.consumerName#</span></th>
					<th class="left">Sex: <span class="radiobutton" style="font-weight: normal;">#dspRadioButton("gender","validate[required]","M","M")##dspRadioButton("gender","validate[required]","F","F")#</span></th>
					<td></td>
				</tr>				
				<tr>
					<th class="left">
						Social Security Number: 
						<cfif document.ssn IS "">
							#dspSSN()#
						<cfelse>
							<span style="font-weight: normal;"> document.ssn</span>
						</cfif>
					</th>
					<th class="left">Race: #dspRaces(document.raceID)#</th>
					<th class="right">
						<strong>Insurance Info: </strong>
						<cfset insurance = ["Medicaid","Medicare","Uninsured"]>
						<span class="radiobutton">
							<cfloop from="1" to="#ArrayLen(insurance)#" index="intRow">
								#dspRadioButton("insurance","validate[required]",intRow,insurance[intRow])#
							</cfloop>
						</span>
					</td>
				</tr>
			</table>
		</fieldset>
		<fieldset>
			<legend class="title">Discharged To</legend>			
			<table cellpadding="6" align="left" style="margin-left:5%;">
				<tr>				
					<th class="left">Address</th>
					<th class="left" colspan="2">Apt ##/Suite</th>
				</tr>		
				<tr>				
					<td>#dspAddress()#</td>
					<td colspan="2" valign="top" style="padding-top: 10px;">#textFieldTag(id="#PARAMS.key#-aptSuite", class="small", name="#PARAMS.key#[aptSuite]",value=document.aptSuite)#</td>			
				</tr>
				<tr>					
					<th class="left">Home/Cell Phone</th>
					<th class="left" colspan="2">Work Phone</th>					
				</tr>
				<tr>					
					<th class="left">#dspPhoneNumber()#</th>
					<th class="left" colspan="2">#dspPhoneNumber("work")#</th>				
				</tr>
				
				<cfloop list='reasonForAdmission <span class="caption">COMAR 10.21.17.10 D(1)</span>,reasonForDischarge <span class="caption">COMAR 10.21.17.10 D(2)</span>' index='label'>
					<tr><th class="left" colspan="3">#humanize(label)#</th></tr>
					<cfset label = wordTruncate(label, 1, "")>
					<tr><th class="left" colspan="3">#textAreaTag(id="#PARAMS.key#-#label#", name="#PARAMS.key#[#label#]", class="normal", value=document[label][1])#</th></tr>
				</cfloop>
			</table>
		
			<table width="100%" style="margin-left: 5%;" cellpadding="6">
				<tr><th class="left" colspan="2">Psychiatric Diagnosis</th></tr>
				<cfloop list='axisI,axisII,axisIII,axisIV,axisV,dischargePrognosis <span class="caption">COMAR 10.21.17.10 D(5)</span>' index='Label'>
					<tr>
						<td width="150px" class="right">#humanize(Label)#:</td>
						<cfset label = wordTruncate(label, 1, "")>
						<td>#textFieldTag(id="#PARAMS.key#-#label#", class="#IIF(label IS 'dischargePrognosis', DE('normal'), DE('small'))#", name="#PARAMS.key#[#label#]", value=document[label][1])#</td>
					</tr>
				</cfloop>
			</table>
		</fieldset>
		
		<fieldset>
			<legend class="title">Current Medications (Dosage & Frequency) <span class="caption">COMAR 10.21.17.10 D(6)</span></legend>
			
			<table class="forms" width="500px" cellpadding="6">
				<tr>
					<cfset medications = model("dischargeInformation_currentMedication").findAll(where="consumerID=#PARAMS.key#")>
					<cfloop list="name,dosage,frequency" index="label">
						<td class="title">#label#</td>
					</cfloop>
					<td class="transparent">
						<div class="btn-group" style="margin: 9px 0;">
							<button class="btn btn-info btn-single addButton" title="Add User"><i class="icon-plus icon-white"></i></button>
						</div>
					</td>
				</tr>
				<tr>
					<cfloop query="medications">
						<cfloop list="name,dosage,frequency" index="label">
							<cfset classStyle = IIF(label IS "name", DE('normal2'), DE('small'))>
							<td>#textFieldTag(id="#medications.id#-medication#label#", name="#medications.id#[medication#label#]", class=classStyle, value=medications['medication#label#'])#</td>
						</cfloop>
						<td class="transparent">
							<div class="btn-group" style="margin: 9px 0;">
								<button class="btn btn-danger btn-single deleteButton" title="Delete User"><i class="icon-trash icon-white"></i></button>
							</div>
						</td>
					</cfloop>
				</tr>
			</table>
			
			<h4>Please briefly describe the steps taken to assist the consumer in their transition out of RCS (Please include agencies contacted):<div class="caption">COMAR 10.21.17.10 D(7)</div></h4>
			<p>#textAreaTag(id="#PARAMS.key#-stepsForTransitionOutOfRCS", class="normal", name="#PARAMS.key#[stepsForTransitionOutOfRCS]", value=document.stepsForTransitionOutOfRCS[1])#</p>
			
			<h4>Family Members/Significant Others Involved in Treatment:</h4>
			
			<table cellpadding="6">
				<cfset family = model("dischargeInformation_family").findAll(where="consumerID = #PARAMS.key#")>
				<cfloop query="family">
					<tr>
						<td>#intRow#.)</td>
						<td>Name</td>
						<td>Addresss</td>
						<td>Phone Number</td>
						<td>Relationship</td>
					</tr>
					<tr>
						<td></td>
						<td>#textFieldTag(id="update-#id#-#name#", name="update[#id#][name]", value=family.name)#</td>
						<td>#dspAddress2("", family)#</td>
						<td>#dspPhoneNumber2("", family)#</td>
						<td>#textFieldTag(id="update-#id#-#relationship#", name="update[#id#][relationship]", value=family.relationship)#
						<td>
							#family.house# #family.street#<br />
							#family.city# #family.state#, #family.zipcode#
						</td>
						<td>#family.phone#</td>
						<td>#family.relationship#</td>
					</tr>
				</cfloop>
				<cfset startIndex = IIF(family.recordCount EQ 0, DE(1), DE(family.recordCount))>
				<cfloop from="#startIndex#" to="4" index="intRow">
					<tr>
						<td>#intRow#.)</td>
						<td>Name</td>
						<td>Addresss</td>
						<td>Phone Number</td>
						<td>Relationship</td>
					</tr>		
					<tr>
						<td></td>
						<td valign="top" style="padding-top: 10px;">#textFieldTag(id="create-#PARAMS.key#-name", name="update[#PARAMS.key#][name]", value="")#</td>
						<td valign="top" style="padding-top: 10px;">#dspAddress2("")#</td>
						<td valign="top" style="padding-top: 10px;">#dspPhoneNumber2("")#</td>
						<td valign="top" style="padding-top: 10px;">#textFieldTag(id="create-#PARAMS.key#-relationship", name="update[#PARAMS.key#][relationship]]", value="")#</td>	
					</tr>
					<cfif intRow LT 4><tr><td align="center" colspan="5" style="padding: 0px;"><hr /></td></cfif>
				</cfloop>
			</table>
		</fieldset>
		
		<fieldset>
			<legend class="title">Summary of Services Provided <span class="caption">COMAR 10.21.17.10 D(3)</span></legend>
			<table class="forms" cellpadding="6">
				<tr>
					<td class="title">Intervention<div class="caption2">(Group Interaction,Treatment Team Meetings, Individual Interaction)</div></td>
					<td class="title">Frequency<div class="caption2">(Number of Times During Stay at SJH)</span></td>
					<td class="title">Duration<div class="caption2">(Total Amount of Time Spent)</div></td>
				</tr>
				<cfset services = {
						"Group Interaction" = { column="groupInteraction", frequency = document.groupInteraction_frequency, duration = document.groupInteraction_duration },
						"Treatment Team Meeting" = { column="treatmentTeamMeeting", frequency = document.treatmentTeamMeeting_frequency, duration = document.treatmentTeamMeeting_duration },
						"Individual Interaction" = {  column="individualInteraction", frequency = document.individualInteraction_frequency, duration = document.individualInteraction_duration },
						"Face-to-Face" = {  column="faceToFace", frequency = document.faceToFace_frequency, duration = document.faceToFace_duration  },
						"PHP" = {  column="php", frequency = document.php_frequency, duration = document.php_duration }
					}>
				<cfloop collection="#services#" item="Label">
					<tr> 
						<td>#Label#</td>
						<td>#textFieldTag(id="#document.id#-#services[label].column#_frequency", class="small", name="#document.id#[#services[label].column#_frequency]", value=services[label].frequency)#</td>
						<td>#textFieldTag(id="#document.id#-#services[label].column#_duration", class="normal", name="#document.id#[#services[label].column#_duration]", value=services[label].duration, maxlength="20")#</td>
					</tr>
				</cfloop>
			</table><br />
			
			<p>Counselor Completing Summary's Signature: #textFieldTag(id="#document.id#-counselorSignature", class="normal2", name="#document.id#[counselorSignature", value=document.counselorSignature, maxlength="30")#</p>
			<h4>Progress Made <span class="caption">COMAR 10.21.17.10 D(4)</span></h4>
			<p>#textAreaTag(id="#PARAMS.key#-progressMade", class="normal", name="#PARAMS.key#[progressMade]", value=document.progressMade[1])#</p>
		</fieldset>
		
		<fieldset>
			<legend class="title">Coordinated Services, when Appropriate <span class="caption">COMAR 10.21.26.04 D(1-9), COMAR 10.21.17.10 C(1)(b)(iii), COMAR 10.21.26.04 C(5)(a-b)</span></legend>			
			<cfset services = getServices()>
			<table cellpadding="6">
				<cfloop from="1" to="#ArrayLen(services)#" index="intRow">
					<cfif ListFindNoCase("3,4,6,9", intRow)>
						<tr>
							<td></td>
							<td class="right"><em>Next Appointment Date</em>:</td>
							<td><input type="text" /></td>
							<td class="right"><em>Time</em>: </td>
							<td>
								<input type="text" />
								<select style="width:75px;margin-top:8px;">
									<option>AM</option>
									<option>PM</option>
								</select>
							</td>
						</tr>
					<cfelseif ListFindNoCase("5,8", intRow)>
						<tr>
							<td></td>
							<td class="right"colspan="4"><em>Dates Attending</em>: <input type="text" /> - <input type="text" /></td>
						</tr>
					</cfif>
					<tr>
						<td>#intRow#.)</td>
						<th class="right" class="left">#services[intRow].label#:</th>
						<td class="left">#textFieldTag(id="#services[intRow].id#-[#PARAMS.key#]serviceName", class="normal3", name="#services[intRow].id#[#PARAMS.key#][serviceName]", value=services[intRow].name, maxlength="75")#</td>
						<th class="right"class="left">Phone Number:</th>
						<td class="left">#dspPhoneNumber2("","","",services[intRow])#</td>
					</tr>		
					<tr>
						<td></td>
						<th class="right">Address:</th>
						<td class="left" colspan="3">	#dspAddress2("", services[intRow])#</td>
					</tr>
					<tr>
						<td></td>
						<td colspan="4" align="center"><hr style="height: 1px; color: lightgray"/></td>
					</tr>
				</cfloop>
			</table>

			<dl>
				<dt><h4>Recommendation of Consumer's Needs for Continued Services <div class="caption">COMAR 10.21.17.10 C(1)(b)(i), COMAR 10.21.17.10 C(1)(b)(ii)</div></h4></dt>
				<dt class="list">#textAreaTag(id="#PARAMS.key#-recommendations", name="#PARAMS.key#[recommendations]", class="normal", value=document.recommendations)#</dt>
				<dt class="list">
					Is the consumer in agreement with the recommendations?
					<span class="radiobutton">
						#dspRadioButton("isAgreementWithRecommendations", "validate[required]", "0", "No")#
						#dspRadioButton("isAgreementWithRecommendations", "validate[required]", "1", "Yes")#
					</span>
				</dt>
				<dt class="list">If no, please explain and give detail of the consumer's involvement int he discharge planning, including the consumer's alternative plan</dt>
				<dt class="list">#textAreaTag(id="#PARAMS.key#-explanations", name="#PARAMS.key#[explanations]", value=document.explanation, class="normal", style="margin-left: 2em;")#</dt>
			</dl>
			
			<table cellpadding="6">
				<cfloop list="consumer,crisisCounselor,clinicalDirector" index="Label">
					<tr>
						<td>#titleize(Label)# Signature: </td>
						<td>
							<cfif label IS "consumer">
								<em>#document.consumerName#</em>
							<cfelse>
								#textFieldTag(id="#PARAMS.key#-#label#Signature", name="#PARAMS.key#[#label#Signature]", class="normal2 validate[required]", value=document['#label#Signature'][1])#
							</cfif>
						</td>
						<td>Date: </td>
						<td>#textFieldTag(id="#PARAMS.key#-#label#SignatureDate", name="#PARAMS.key#[#label#SignatureDate]", class="normal date", value=document['#label#SignatureDate'][1])#</td>
					</tr>
				</cfloop>
				
				<tr><td colspan="4" class="left">*** Sign here to indicate receipt of medications upon discharge: <u>#document.consumerName#</u></td></tr>
				<tr><td colspan="4" class="left">Consumer Name (Print): <u>#document.consumerName#</u></td></tr>
			</table>
		</fieldset>
	</form>
	<cfif PARAMS.key NEQ 0>#dspFormButtons(key=PARAMS.key, action=PARAMS.controller)#</cfif>
</cfoutput>